import { ErrorName, EventName } from '@/types/reporter';

const prefix = 'atk';

export const EventNameMap: Record<EventName, string> = {
  [EventName.FetchRuleSuccess]: `${prefix}_fetch_rule_success`, // 规则获取成功
  [EventName.FetchRuleFail]: `${prefix}_fetch_rule_fail`, // 规则获取失败
  [EventName.RuleCompileSuccess]: `${prefix}_rule_compile_success`, // 规则编译成功
  [EventName.RuleCompileFail]: `${prefix}_rule_compile_fail`, // 规则编译失败
  [EventName.ValidateSuccess]: `${prefix}_validate_success`, // 规则校验成功
  [EventName.ValidateFail]: `${prefix}_validate_fail`, // 规则校验失败
  [EventName.DataCenterUpdateTime]: `${prefix}_data_center_update_time`, // 任务中心更新时间上报
  [EventName.ServerTiming]: `${prefix}_server_timing`, // 请求耗时上报
  [EventName.CacheTimeout]: `${prefix}_cache_timeout`, // 请求耗时上报
  [EventName.StageTiming]: `${prefix}_stage_timing`, // 请求耗时上报
  [EventName.CompileRuleTiming]: `${prefix}_compile_rule_timing`, // 请求耗时上报
};

export const ErrorNameMap: Record<ErrorName, string> = {
  [ErrorName.JsError]: `${prefix}_js_error`,
  [ErrorName.PresetError]: `${prefix}_preset_error`,
  [ErrorName.CustomPresetError]: `${prefix}_custom_preset_error`,
};
